﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EasyClassServer.Net;
using Newtonsoft.Json.Linq;
using EasyClassServer.Application;
using EasyClassServer.Application.App;

namespace EasyClassServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            Application.Application.LoadApp(typeof(Application.Email.Email));
            Application.Application.LoadApp(typeof(Application.Register.Register));
            Application.Application.LoadApp(typeof(Application.Log.Login));
            Application.Application.LoadApp(typeof(Application.ChangePassword.Password));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            HttpServer server = new Net.HttpServer(80);
            server.HttpGotRequest += Server_HttpGotRequest;
            server.Start();
        }

        private HttpResponseArgs Server_HttpGotRequest(HttpArgs argument)
        {
            return Application.Application.Handle(argument);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            TestModel model = new TestModel();
            var result = model.Update(new Dictionary<string, object>
            {
                { "age>", 17 },
                { "name", "张三" }
            }, new Dictionary<string, object>
            {
                { "age", 18 },
                { "sex", "男" }
            });
            return;
        }

        class TestModel : BaseModel
        {
            protected override string TableName => "person";

        }
    }
}
